package com.example.demo.response.transform;

import com.example.demo.entity.Wish;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

public class  IndexTransform   {

    public Map<Integer, Object> getWishs(List<Wish> wishs){
        Map<String,Object> item = new HashMap<>();
        Map<Integer,Object> list = new HashMap<>();
        Integer i = 0;
        for (Wish wish : wishs){
            item.put("id",wish.id);
            item.put("title",wish.title);
            item.put("detail",wish.detail);
            item.put("reward",wish.lan(wish.reward));
            item.put("grade",wish.lan(wish.grade));
            item.put("created_at",wish.created_at.substring(0,10));
            list.put(i,item);
            i++;
        }
        return list;
    }

    public Map<String, Object> getWishDetail(Wish wish){
        Map<String,Object> item = new HashMap<>();
        item.put("id",wish.id);
        item.put("title",wish.title);
        item.put("detail",wish.detail);
        item.put("reward",wish.lan(wish.reward));
        item.put("grade",wish.lan(wish.grade));
        item.put("created_at",wish.created_at.substring(0,10));
        return item;
    }

}
